import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class ProblemCaseAdministrator {

	private ArrayList<Problemcase> problemcases = new ArrayList<Problemcase>();

	public ProblemCaseAdministrator() {
	}

	public ProblemCaseAdministrator(int year, int month, int day, int numberOfFiles) {

	}

	public void addProblemcase(Problemcase pc) {
		if (pc == null)
			throw new IllegalArgumentException("Problemcase must not be null");

		problemcases.add(pc);
	}

	public ArrayList<Problemcase> getList() {
		return problemcases;
	}

	public void generateTestData() {
		int i = 0;

		while (i <= 6000) {
			Problemcase pc = new Problemcase();

			addProblemcase(pc);
			i++;
		}
	}

	public void exportDateToDisk(String path, String filename) {
		try {
			File file = new File("C:\\test\\" + filename + "");
			FileWriter fw = null;

			if (file.exists())
				System.out.println("Datei existiert bereits.");
			else
				System.out.println("Datei wird erstellt.");

			fw = new FileWriter(file.getPath(), true);

			for (Problemcase p : getList()) {
				fw.write(p.toString());
			}
			fw.flush();
			fw.close();
			problemcases.removeAll(getList());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
